package spring.module.scheduling;

import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;

import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;

/**
 * 工具
 *  
 * @author Lucky Yang
 */
@UtilityClass
public class Nap {
    private static final SecureRandom sr = new SecureRandom();

    @SneakyThrows
    public int random(int milliseconds) {
        int interval = sr.nextInt(milliseconds);
        TimeUnit.MILLISECONDS.sleep(interval);
        return interval;
    }

    @SneakyThrows
    public int fix(int milliseconds) {
        TimeUnit.MILLISECONDS.sleep(milliseconds);
        return milliseconds;
    }
}
